package main

const (
	INT_MAX = 1<<31 - 1
	INT_MIN = -INT_MAX - 1
)

func reverse(x int) int {

	rev := 0

	for x > 0 {
		s := x % 10
		rev := rev*10 + s
		x = x / 10
	}

	if rev > INT_MAX || rev < INT_MIN {
		return 0
	}

	return rev
}
